/**
 * com.chaeron.GPS - An API for access to GPS devices.
 *
 *
 * Copyright (c) 2001, 2002 Chaeron Corporation,
 * All rights reserved.
 * 
 * Chaeron grants you a non-exclusive license to use, modify and re-distribute
 * this program under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version, provided that this copyright notice and 
 * license appear on all copies of the software.
 * 
 * Software is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR
 * IMPLIED REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE
 * HEREBY EXCLUDED. THE ENTIRE RISK ARISING OUT OF USING THE SOFTWARE IS ASSUMED
 * BY THE LICENSEE. See the GNU General Public License for more details.
 *
 * CHAERON AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY
 * LICENSEE OR ANY THIRD PARTY AS A RESULT OF USING OR DISTRIBUTING SOFTWARE.
 * IN NO EVENT WILL CHAERON OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE,
 * PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL
 * OR PUNITIVE DAMAGES, HOWEVER CAUSED AN REGARDLESS OF THE THEORY OF LIABILITY,
 * ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF CHAERON HAS
 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

 * @version     1.02
 * @author      Andrzej Jan Taramina, Chaeron Corporation
 *              andrzej@chaeron.com
 */

package com.chaeron.GPS.event;

//***************************************************************************
//*
//*     Imports
//*
//***************************************************************************/

import com.chaeron.GPS.*;
import com.chaeron.GPS.exception.*;

import java.util.*;

//***************************************************************************
//*
//*     GPSEvent Class definition
//*
//***************************************************************************/

/**
 * The GPSEvent class is used to communicate all GPS events to external listeners
 *
 */

public class GPSEvent
{
	
	//***************************************************************************
	//*
	//*     Constant definitions
	//*
	//***************************************************************************/
	
	// Type definitions.  Must be powers of 2 to allow binary testing of values
	
	/**
	 * Undefined Event Type
	 */
	public final static int         GPS_EVENT_UNDEFINED              	= 0x00000000;
	
	/**
	 * Unkown Event Type
	 */
	public final static int         GPS_EVENT_ERROR              	   	= 0x00000001;
	
	/**
	 * Unknown Data Event Type
	 */
	public final static int         GPS_EVENT_UNKNOWN_DATA            	= 0x00000002;
	
	/**
	 * GPS Raw Data ( regardless of protocol) Event Type
	 */
	public final static int         GPS_EVENT_RAW_DATA	    	        = 0x00000004;
	
	/**
	 * NMEA Sentence Event Type
	 */
	public final static int         GPS_EVENT_NMEA_SENTENCE             = 0x00000008;
	
	/**
	 * Garmin Packet Event Type
	 */
	public final static int         GPS_EVENT_GARMIN_PACKET             = 0x00000010;
	
	/**
	 * GPS Initialized Event Type
	 */
	public final static int         GPS_EVENT_INITIALIZED               = 0x00000020;
	
	/**
	 * GPS Capabilites Initialized Event Type
	 */
	public final static int         GPS_EVENT_CAPABILITIES              = 0x00000040;
	
	/**
	 * Position Event Type
	 */
	public final static int         GPS_EVENT_POSITION                  = 0x00000080;
	
	/**
	 * Velocity Event Type
	 */
	public final static int         GPS_EVENT_VELOCITY                  = 0x00000100;
	
	/**
	 * Time Event Type
	 */
	public final static int         GPS_EVENT_TIME                  	= 0x00000200;
	
	/**
	 * Time Event Type
	 */
	public final static int         GPS_EVENT_BEARING                  	= 0x00000400;
	
	/**
	 * Satellites Active Event Type
	 */
	public final static int         GPS_EVENT_SATELLITES_ACTIVE         = 0x00000800;
	
	/**
	 * Satellites in View Event Type
	 */
	public final static int         GPS_EVENT_SATELLITES_INVIEW         = 0x00001000;
	
	/**
	 * General Navigation Event Type
	 */
	public final static int         GPS_EVENT_NAVIGATION_GENERAL       	= 0x00002000;
	
	
	/**
	 * Destination Navigation Event Type
	 */
	public final static int         GPS_EVENT_NAVIGATION_DESTINATION    = 0x00004000;
	
	/**
	 * Route Navigation Event Type
	 */
	public final static int         GPS_EVENT_NAVIGATION_ROUTE    		= 0x00008000;
	
	/**
	 * Simple Position Event Type
	 */
	public final static int         GPS_EVENT_SIMPLE_POSITION    		= 0x00010000;
	
	/**
	 * Magnetic Heading Event Type
	 */
	public final static int         GPS_EVENT_HEADING			   		= 0x00020000;
	
	/**
	 * Position Error Event Type
	 */
	public final static int         GPS_EVENT_POSITION_ERROR			= 0x00040000;
	
	/**
	 * Altitude Event Type
	 */
	public final static int         GPS_EVENT_ALTITUDE					= 0x00080000;
	
	/**
	 * Records Event Type
	 */
	public final static int         GPS_EVENT_RECORDS					= 0x00100000;
	
	/**
	 * Waypoint Event Type
	 */
	public final static int         GPS_EVENT_WAYPOINT					= 0x00200000;
	
	/**
	 * Xfer Complete Event Type
	 */
	public final static int         GPS_EVENT_XFER_COMPLETE				= 0x00400000;
	
	/**
	 * Waypoint Download Complete Event Type
	 */
	public final static int         GPS_EVENT_WAYPOINT_TRANSFER_COMPLETE = 0x00800000;
	
	/**
	 * Route Header Event Type
	 */
	public final static int         GPS_EVENT_ROUTE_HEADER				= 0x01000000;
	
	/**
	 * Route Link Data Event Type
	 */
	public final static int         GPS_EVENT_ROUTE_LINK_DATA			= 0x02000000;
	
	/**
	 * Route Download Complete Event Type
	 */
	public final static int         GPS_EVENT_ROUTE_TRANSFER_COMPLETE 	= 0x04000000;
	
	/**
	 * Track Header Event Type
	 */
	public final static int         GPS_EVENT_TRACK_HEADER				= 0x08000000;
	
	/**
	 * Track Point Event Type
	 */
	public final static int         GPS_EVENT_TRACK_POINT				= 0x10000000;
	
	/**
	 * Route Download Complete Event Type
	 */
	public final static int         GPS_EVENT_TRACK_TRANSFER_COMPLETE 	= 0x20000000;
	
	/**
	 * Map Datum Event Type
	 */
	public final static int         GPS_EVENT_MAPDATUM 					= 0x40000000;
	
	/**
	 * Do not parse Event Types
	 */
	public final static int         GPS_EVENT_DO_NOT_PARSE				= GPS_EVENT_NMEA_SENTENCE | GPS_EVENT_GARMIN_PACKET;
	
	
	
	//***************************************************************************
	//*
	//*     Attributes
	//*
	//***************************************************************************/
	
	private	int						type								= GPS_EVENT_UNDEFINED;
	private GPSException			exception							= null;
	private Object					value								= null;
	private int						extraValue							= 0;
	
	
	//***************************************************************************
	//*
	//*     Constructors
	//*
	//***************************************************************************/
	
	/**
	 * Create an GPSEvent instance
	 */
	
	protected GPSEvent()
	{  
	}
	
	
	/**
	 * Create an GPSEvent instance with the given type and value
	 *
	 * @param	type		type of GPS event to be created
	 * @param	value		value to be put in event
	 */
	
	public GPSEvent( int type, GPSValue value )
	{  
		this.type 		= type;
		this.value 		= value;
	}
	
	
	/**
	 * Create an GPSEvent instance with the given type and value and GPS Exception
	 *
	 * @param	type		type of GPS event to be created
	 * @param	value		value to be put in event
	 * @param	exception	GPS Exception
	 */
	
	public GPSEvent( int type, Object value, GPSException exception )
	{  
		this.type 		= type;
		this.value 		= value;
		this.exception 	= exception;
	}
	
	
	/**
	 * Create an GPSEvent instance with the given type, value and extra value.  The extra value is
	 * an integer and is currently only used for a GPS_EVENT_RAW_DATA event type to return the length
	 * of the raw data.
	 *
	 * @param	type		type of GPS event to be created
	 * @param	value		value to be put in event
	 * @param	extraValue	extra value
	 */
	
	public GPSEvent( int type, Object value, int extraValue )
	{  
		this.type 		= type;
		this.value 		= value;
		this.extraValue = extraValue;
	}
	
	
	//***************************************************************************
	//*
	//*     Accessor Methods
	//*
	//***************************************************************************/
	
	/**
	 * Get the type  
	 *
	 * @return		type
	 */
	
	public int getType()
	{
		return( type );   
	}
	
	
	/**
	 * Set the type  
	 *
	 * @param		type	the type
	 */
	
	public void setType( int type )
	{
		this.type = type;  
	}
	
	
	/**
	 * Get the exception value  
	 *
	 * @return		exception value 
	 */
	
	public GPSException getException()
	{
		return( exception );   
	}
	
	
	/**
	 * Set the exception value 
	 *
	 * @param		exception	exception value 
	 */
	
	public void setException( GPSException exception )
	{
		this.exception = exception;  
	}
	
	
	/**
	 * Get the value object
	 *
	 * @return		value object
	 */
	
	public Object getValue()
	{
		return( value );   
	}
	
	
	/**
	 * Set the value object  
	 *
	 * @param		value	the value object
	 */
	
	public void setValue( Object value )
	{
		this.value = value;  
	}
	
	
	/**
	 * Get the extra value 
	 *
	 * @return		extra value 
	 */
	
	public int getExtraValue()
	{
		return( extraValue );   
	}
	
	
	/**
	 * Set the extra value  
	 *
	 * @param		value	the value object
	 */
	
	public void setExtraValue( int extraValue )
	{
		this.extraValue = extraValue;  
	}
	
}
